<template>
  <el-container style="height: 100%; border: 1px solid #eee">
  <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
    <el-menu :default-openeds="['1', '1']">
      <el-submenu index="1">
        <template slot="title"><i class="el-icon-message"></i>首页</template>
        <el-menu-item-group>
          <el-menu-item index="1-1" @click="Shou()">首页</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title"><i class="el-icon-message"></i>商品信息</template>
        <el-menu-item-group>
          <template slot="title">商品信息</template>
          <el-menu-item index="2-1" @click="listHandl()">商品列表</el-menu-item>
          <el-menu-item index="2-2" @click="addHandl()">商品新增</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title"><i class="el-icon-message"></i>用户信息</template>
        <el-menu-item-group>
          <template slot="title">用户信息</template>
          <el-menu-item index="1-1" @click="yhlistHandl()">用户列表</el-menu-item>
          <el-menu-item index="1-2" @click="yhaddHandl()">用户新增</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="4">
        <template slot="title"><i class="el-icon-message"></i>订单信息</template>
        <el-menu-item-group>
          <template slot="title">订单信息</template>
          <el-menu-item index="1-1" @click="ddlistHandl()">订单列表</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </el-aside>

  <el-container>
    <el-header style="text-align: right; font-size: 12px">
      <el-dropdown>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>查看</el-dropdown-item>
          <el-dropdown-item>新增</el-dropdown-item>
          <el-dropdown-item>删除</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <span>luckin coffee</span>
      <button @click="logOuts">退出</button>
    </el-header>
    <el-main>
      <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
</template>

<script>
// @ is an alias to /src
import { logOut } from '../utils/auth'
import { loginOf } from '../api/user'
export default {
  name: 'home',
  components: {
  },
  async created(){
    if(localStorage.getItem('token')){

    }else{
      this.$router.push({
        name:'login'
      })
    }
  },
  methods:{
    Shou(){
      this.$router.push({
        name:"zy"
      })
    },
    logOuts(){
      logOut()
      this.$router.push({
        name:'login'
      })
    },
    listHandl(){
      this.$router.push({
        name:"user"
      })
    },
    addHandl(){
      this.$router.push({
        name:'add'
      })
    },
    yhlistHandl(){
      this.$router.push({
        name:"yh"
      })
    },
    yhaddHandl(){
      this.$router.push({
        name:'yhAdd'
      })
  },ddlistHandl(){
    this.$router.push({
      name:"order"
    })
    },
  data() {
      return {
      }
    }
}
}
</script>
<style>
html,body{
  height: 100%;
}
.el-container{
  background: #fff;
}
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }
  .el-aside {
    color: #333;
  }
  button{
    border: 0;
    margin-left:20px;
    background: rgba(255, 255,255, 0)
  }
</style>
